package com.h2cloud.redisTest;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import redis.clients.jedis.Jedis;

import java.util.Set;

/**
 * @Package: com.h2cloud.redisTest
 * @ClassName: TestSet
 * @Author: h2cloud
 * @CreateTime: 2021/4/17 8:50 下午
 * @Description:
 */
public class TestSet {
    private Jedis jedis;

    @Before
    public void before() {
        this.jedis = new Jedis("127.0.0.1", 6379);
    }

    @After
    public void after() {
        jedis.close();
    }


    //测试SET相关
    @Test
    public void testSet() {

        //sadd
        jedis.sadd("names", "1zhangsan1", "lisi");

        //smembers
        Set<String> names = jedis.smembers("names");
        for (String str : names) {
            System.out.println(str);
        }
        //sismember
        jedis.sismember("names", "xiaochen");

        //...
    }

}
